﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NextAction.Domain.Entities;
using NextAction.WebUI.Models;

namespace NextAction.WebUI.Binders
{
    public class GtdTaskModelBinder : IModelBinder
    {
        private const string sessionKey = "GtdTask";

        public object BindModel(ControllerContext controllerContext,
        ModelBindingContext bindingContext)
        {
            GtdTask task = (GtdTask)controllerContext.HttpContext.Session[sessionKey];
            if (task == null)
            {
                task = new GtdTask();
                controllerContext.HttpContext.Session[sessionKey] = task;
            }
            return task;
        }
    }

}